package com.zprmb.udzt;

import java.text.DecimalFormat;

import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zprmb.udzt.ll.BaseHelper;
import com.zprmb.udzt.view.WaveHelper;
import com.zprmb.udzt.view.WaveView;

public class Total_assets_Detail extends BaseActivity implements OnClickListener{
	private RelativeLayout freeze,rl_uplan_old,rl_uplan_new;
	private LinearLayout freeze_detail,li_uplan_old,li_uplan_new;
	private WaveView waveView;
	private TextView tv_customer;
	private Double allAssetDueInPrincipal;  // 代收本金【定期理财】
	private Double allAssetDueInInterest;  // 代收利息【定期理财】
	private Double allAssetDueInAddInterest;  //  代收加息券利息【定期理财】
	private Double allAssetDueInAfterAddInterest;  //  平台附加利息【定期理财】
	private WaveHelper waveHelperl;
	private ImageView img_back,img_free,img_new_info,img_old_info;
	private String total_assets,keyong,frozen,ztdj,monthwin,lcb,fldj,txdj,current,fixrealdue,exedue,allFixedRealDueIn,rmbDueInAll,userRateCouponDueInterest;
	DecimalFormat df = new DecimalFormat("###0.00");
	private TextView tv_total_assets,tv_keyong,tv_frozen,tv_ztdj,tv_monthwin,tv_lcb,tv_fldj;
	private TextView tv_txdj,tv_current,tv_exedue,tv_rmbDueInAll,tv_userRateCouponDueInterest;
	private RelativeLayout rl_back;
	private TextView tv_new_total,tv_old_total,tv_uplan_new_pl;
	private TextView tv_uplan_new_benxi,tv_uplan_old_benxi;
	private TextView tv_uplan_new_coupon,tv_uplan_old_coupon;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_total_assets);
		 BbtApplication.getInstance().addActvity(this);
		setImmersionStatus();
		 frozen=getIntent().getStringExtra("frozen");
		 ztdj=getIntent().getStringExtra("ztdj");
		 monthwin=getIntent().getStringExtra("monthwin");
		 lcb=getIntent().getStringExtra("lcb");
		 fldj=getIntent().getStringExtra("fldj");
		 txdj=getIntent().getStringExtra("txdj");
		 current=getIntent().getStringExtra("current");
		 fixrealdue=getIntent().getStringExtra("fixrealdue");
		 exedue=getIntent().getStringExtra("exedue");
		 total_assets=getIntent().getStringExtra("total_assets"); 
		 keyong=getIntent().getStringExtra("keyong");
		 allFixedRealDueIn=getIntent().getStringExtra("allFixedRealDueIn");
		 rmbDueInAll=getIntent().getStringExtra("rmbDueInAll");
		 userRateCouponDueInterest=getIntent().getStringExtra("userRateCouponDueInterest");
		 allAssetDueInPrincipal=getIntent().getDoubleExtra("allAssetDueInPrincipal", 0);  // 代收本金【定期理财】
		 allAssetDueInInterest=getIntent().getDoubleExtra("allAssetDueInInterest", 0);// 代收利息【定期理财】
		 allAssetDueInAddInterest=getIntent().getDoubleExtra("allAssetDueInAddInterest", 0);//  代收加息券利息【定期理财】
		 allAssetDueInAfterAddInterest=getIntent().getDoubleExtra("allAssetDueInAfterAddInterest", 0);//  平台附加利息【定期理财】
		 initView();
		 tv_uplan_new_pl.setText(allAssetDueInAfterAddInterest+"");
		 tv_new_total.setText(df.format(allAssetDueInPrincipal+allAssetDueInInterest+allAssetDueInAddInterest+allAssetDueInAfterAddInterest));//新定期总收益 （本息加加息券）
		 tv_old_total.setText(df.format(Double.parseDouble(allFixedRealDueIn)+Double.parseDouble(userRateCouponDueInterest)));//老定期总收益 （本息加加息券）
		 tv_uplan_new_benxi.setText(df.format(allAssetDueInPrincipal+allAssetDueInInterest));//新定期本息
		 tv_uplan_new_coupon.setText(df.format(allAssetDueInAddInterest));//新定期加息券
		 tv_uplan_old_benxi.setText(df.format(Double.parseDouble(allFixedRealDueIn)));//老定期本息
		 tv_uplan_old_coupon.setText(df.format(Double.parseDouble(userRateCouponDueInterest)));//老定期加息券
		 tv_current.setText(df.format(Double.parseDouble(current)));
		 tv_exedue.setText(df.format(Double.parseDouble(exedue)));
//		 tv_fldj.setText(df.format(Double.parseDouble(fldj)));
		 tv_frozen.setText(df.format(Double.parseDouble(frozen)));
		 tv_keyong.setText(df.format(Double.parseDouble(keyong)));
		 tv_lcb.setText(df.format(Double.parseDouble(lcb)));
//		 tv_monthwin.setText(df.format(Double.parseDouble(monthwin)));
		 tv_total_assets.setText(df.format(Double.parseDouble(total_assets)));
		 tv_txdj.setText(df.format(Double.parseDouble(txdj)));
		 tv_ztdj.setText(df.format(Double.parseDouble(ztdj)));
		 tv_rmbDueInAll.setText(df.format(Double.parseDouble(rmbDueInAll)));
		 tv_userRateCouponDueInterest.setText(df.format(Double.parseDouble(userRateCouponDueInterest)));
		
	}
	 private void initView() {
		// TODO Auto-generated method stub
		 tv_current=(TextView)findViewById(R.id.tv_current);
		 img_free=(ImageView)findViewById(R.id.img_free);
		 li_uplan_old=(LinearLayout)findViewById(R.id.li_uplan_old);
		 li_uplan_new=(LinearLayout)findViewById(R.id.li_uplan_new);
		 rl_uplan_old=(RelativeLayout)findViewById(R.id.rl_uplan_old);
		 rl_uplan_new=(RelativeLayout)findViewById(R.id.rl_uplan_new);
		 img_new_info=(ImageView)findViewById(R.id.img_new_info);
		 img_old_info=(ImageView)findViewById(R.id.img_old_info);
		 tv_exedue=(TextView)findViewById(R.id.tv_exedue);
		 tv_uplan_new_pl=(TextView)findViewById(R.id.tv_uplan_new_pl);
		 tv_uplan_new_coupon=(TextView)findViewById(R.id.tv_uplan_new_coupon);
		 tv_uplan_old_coupon=(TextView)findViewById(R.id.tv_uplan_old_coupon);
		 tv_uplan_new_benxi=(TextView)findViewById(R.id.tv_uplan_new_benxi);
		 tv_uplan_old_benxi=(TextView)findViewById(R.id.tv_uplan_old_benxi);
		 tv_new_total=(TextView)findViewById(R.id.tv_new_total);
		 tv_old_total=(TextView)findViewById(R.id.tv_old_total);
//		 tv_fldj=(TextView)findViewById(R.id.tv_fldj);
		 tv_frozen=(TextView)findViewById(R.id.tv_frozen);
		 tv_keyong=(TextView)findViewById(R.id.tv_keyong);
		 tv_lcb=(TextView)findViewById(R.id.tv_lcb);
//		 tv_monthwin=(TextView)findViewById(R.id.tv_monthwin);
		 tv_total_assets=(TextView)findViewById(R.id.tv_total_assets);
		 tv_txdj=(TextView)findViewById(R.id.tv_txdj);
		 tv_new_total=(TextView)findViewById(R.id.tv_new_total);
		 tv_ztdj=(TextView)findViewById(R.id.tv_ztdj);
		 tv_rmbDueInAll=(TextView)findViewById(R.id.tv_rmbDueInAll);
		 tv_userRateCouponDueInterest=(TextView)findViewById(R.id.tv_userRateCouponDueInterest);
		 freeze_detail=(LinearLayout)findViewById(R.id.freeze_detail);
			freeze=(RelativeLayout)findViewById(R.id.freeze);
			img_back=(ImageView)findViewById(R.id.img_back);
			rl_back=(RelativeLayout)findViewById(R.id.rl_back);
			rl_uplan_old.setOnClickListener(this);
			rl_uplan_new.setOnClickListener(this);
			rl_back.setOnClickListener(this);
			img_back.setOnClickListener(this);
			waveView=(WaveView)findViewById(R.id.wave);
			waveHelperl=new WaveHelper(waveView);
			waveHelperl.start();
			tv_customer=(TextView)findViewById(R.id.enterprise_tel);
			tv_customer.setOnClickListener(this);
			freeze.setOnClickListener(this);
			imgchange();
	}
	private void setImmersionStatus() {
			if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
				getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
			}
		}
	 @Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if(waveHelperl!=null){
			
			waveHelperl.cancel();
		}
	
			BbtApplication.getInstance().removeActvity(this);
		
	}
private void imgchange(){
	if(freeze_detail.getVisibility()==View.GONE){
		
		freeze_detail.setVisibility(View.VISIBLE);
		img_free.setImageResource(R.drawable.icon_up);
	}else{
		freeze_detail.setVisibility(View.GONE);
		img_free.setImageResource(R.drawable.icon_down);
	}
}
private void imgchange_old(){
	if(li_uplan_old.getVisibility()==View.GONE){
		
		li_uplan_old.setVisibility(View.VISIBLE);
		img_old_info.setImageResource(R.drawable.icon_up);
	}else{
		li_uplan_old.setVisibility(View.GONE);
		img_old_info.setImageResource(R.drawable.icon_down);
	}
}
private void imgchange_new(){
	if(li_uplan_new.getVisibility()==View.GONE){
		
		li_uplan_new.setVisibility(View.VISIBLE);
		img_new_info.setImageResource(R.drawable.icon_up);
	}else{
		li_uplan_new.setVisibility(View.GONE);
		img_new_info.setImageResource(R.drawable.icon_down);
	}
}

	@Override
	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch(arg0.getId()){
		case R.id.freeze:
			imgchange();
			break;
		case R.id.img_back:
			finish();
			break;
		case R.id.rl_back:
			finish();
			break;
		case R.id.rl_uplan_old:
			imgchange_old();
			break;
		case R.id.rl_uplan_new:
			imgchange_new();
			break;

		case R.id.enterprise_tel:
			BaseHelper.showDialog2(this, "拨号", "400-0101-016", 1);
			break;
		
		}
		
	}

}
